using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class UDF_LookupTypeMap : EntityTypeConfiguration<UDF_LookupType>
    {
        public UDF_LookupTypeMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.Name, t.Code, t.Type, t.Source, t.ID_Field, t.Name_Field, t.Name2_Field, t.Project });

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Code)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Type)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.Source)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ID_Field)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Name_Field)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Name2_Field)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Project)
                .IsRequired()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("UDF_LookupType");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Source).HasColumnName("Source");
            this.Property(t => t.ID_Field).HasColumnName("ID_Field");
            this.Property(t => t.Name_Field).HasColumnName("Name_Field");
            this.Property(t => t.Name2_Field).HasColumnName("Name2_Field");
            this.Property(t => t.Project).HasColumnName("Project");
        }
    }
}
